﻿<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
    </startup>
    <connectionStrings>
        <add name="DB" connectionString="
             DataSource=localhost;Port=3050;
             Database=C:\Repos\Firebird-Reporter\FireReporter\bin\Debug\SKD_STORK.FDB;
             User=SYSDBA;Password=;
             Charset=WIN1251;
             Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;
             ServerType=0;Dialect=3;
             "/>
    </connectionStrings>
    <appSettings>
        <add key="SqlQuery" value="
             SELECT
             R.DESCRIPTION,
             SUBSTRING(E.DATE_RECORD FROM 9 FOR 8),
             TRIM(T.TOKEN_CODE_CARD),
             IIF(E.USER_ID = 1, 'Админ-р', TRIM(U.USER_FAM)),
             IIF(E.USER_ID = 1, '', TRIM(U.USER_NAME))
             FROM EVENT_LOG AS E
             JOIN READERS AS R ON E.READER_ID = R.READER_ID
             JOIN TOKENS AS T ON E.TOKEN_ID = T.TOKEN_ID
             JOIN USERS AS U ON E.USER_ID = U.USER_ID
             WHERE E.EVENT_CODE = 1 AND E.ADATE_CTRL >= DATEADD(-70 DAY TO CURRENT_DATE)
             ORDER BY R.DESCRIPTION, E.DATE_RECORD
             "/>
        
        <add key="SaveFile" value="true"/><!-- Save debug files: true/false -->
        <add key="SendMail" value="true"/><!-- Send result mails: true/false -->

        <!-- Sender's name and email -->
        <add key="Sender" value="Hotel Reporter [sender@gmail.com]"/>

        <!-- TEXT mails -->
        <add key="TextFile" value="report.txt"/>
        <add key="TextRecipients" value="
             text1@gmail.com,
             tex2@gmail.com
             "/>
        <add key="TextSubject" value ="Отчет за 7 дней (TEXT)"/>
        <add key="TextHeader" value ="Отчет по открыванию дверей:\n"/>
        <add key="TextFooter" value ="\n--\nНе пересылайте это посторонним лицам."/>
        <add key="TextSeparator" value="  "/>

        <!-- HTML mails -->
        <add key="HtmlFile" value="report.html"/>
        <add key="HtmlRecipients" value="
             html1@gmail.com,
             html2@gmail.com
             "/>
        <add key="HtmlSubject" value="Отчет за 7 дней (HTML)"/>
        <add key="HtmlStyle" value="
             tr:nth-of-type(even){background-color: #f3f3f3;}
             td{border-right: 1px solid #ddd; text-align: center; padding: 4px 5px;}
             "/>
        <add key="HtmlHeader" value="[h3]Отчет по открыванию дверей:[/h3]"/>
        <add key="HtmlTitles" value="
             Номер,
             Время,
             Жетон,
             Кто,
             Имя
             "/>
        <add key="HtmlFooter" value="[p]Не пересылайте это посторонним лицам.[/p]"/>

        <add key="FailRecipients" value="
             Admin [admin@gmail.com]
             "/>
    </appSettings>
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="Network"><!-- SMTP server -->
                <network defaultCredentials="false"
                         host="smtp.gmail.com" port="587" 
                         userName="sender@gmail.com" password=""
                         enableSsl="true" />
            </smtp>
        </mailSettings>
    </system.net>
    <system.diagnostics>
        <trace autoflush="true" indentsize="2">
            <listeners>
                <add name="console" type="System.Diagnostics.ConsoleTraceListener" initializeData="false"/>
                <add name="log" type="System.Diagnostics.TextWriterTraceListener" initializeData="Trace.log"/>
                <remove name="Default"/>
            </listeners>
        </trace>
    </system.diagnostics>
</configuration>
